<?php
class StaticPagesController extends AppController {
	var $name = 'StaticPages';
	var $uses = array('static_pages.StaticPage');
	var $view = 'Theme';
	var $theme = 'qat';
    var $helpers = array('text');
	var $layout = 'news';
	var $models = array(
		'Page'		=>	array(
			'plugin'	=>	'static_pages',
			'name'		=>	'StaticPage'
		)
	);
	function index() {}
	   
	function view($alias = null) {
	    if($alias != null){
    		$detail = $this->{$this->models['Page']['name']}->find('first', array(
    			'conditions'	=>	array(
    				"{$this->models['Page']['name']}.alias" => $alias,
                    "is_published"   => 1
    			),
    			'fields'		=>	array('title', 'alias', 'content','created')
    		));
        }else{
    		$detail = $this->{$this->models['Page']['name']}->find('first', array(
    			'conditions'	=>	array(
                    "is_published"   => 1
    			),
    			'fields'		=>	array('title', 'alias', 'content')
    		));
        }
		$others = $this->{$this->models['Page']['name']}->find('all', array(
			'conditions'	=>	array(
				"{$this->models['Page']['name']}.alias <>" => $detail["{$this->models['Page']['name']}"]["alias"],
                "is_published"   => 1
			),
			'fields'		=>	array('title', 'alias', 'content')
		));
		$this->set(compact('detail', 'others'));
	}
}
?>